//
//  TSResultViewController.swift
//  TopStock
//
//  Created by dyd on 2017/8/10.
//  Copyright © 2017年 dyd. All rights reserved.
//

import UIKit

class TSResultViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
    @IBAction func backToLoginView(_ sender: Any) {
        print("backToLoginView")
        
    }
    
    @IBAction func backToRegisterView(_ sender: Any) {
        self.dismiss(animated: true, completion: nil)
    }

    @IBAction func authenticAction(_ sender: UIButton)
    {
        print("authenticAction")
        showRootView(authentic: true)
    }
    
    @IBAction func showRootViewAction(_ sender: UIButton)
    {
        print("showRootViewAction")
        showRootView(authentic: false)
    }
    
    func showRootView(authentic:Bool)
    {
        if authentic{
            let storyBoard : UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
            let rootViewController = storyBoard.instantiateViewController(withIdentifier: "RootViewController") as! TSRootViewController
            rootViewController.isFromAuthentic = true
            let rootNav = UINavigationController.init(rootViewController: rootViewController)
            self.present(rootNav, animated: true, completion: nil)
        }else{
            NotificationCenter.default.post(name:NSNotification.Name(rawValue: "webViewRefresh"), object: nil, userInfo: ["isAuthentic":authentic])
            self.presentingViewController?.presentingViewController?.presentingViewController?.dismiss(animated: true, completion: nil)
        }
    }
    
    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
